package cz.muni.fi.pa165.sme.web.system;

import cz.muni.fi.pa165.sme.web.pages.LoginPage;
import cz.muni.fi.pa165.sme.web.pages.TemplatePage;
import cz.muni.fi.pa165.sme.web.pages.burnedCalories.CaloriesAddPage;
import cz.muni.fi.pa165.sme.web.pages.burnedCalories.CaloriesListPage;
import cz.muni.fi.pa165.sme.web.pages.sportActivity.ActivityAddPage;
import cz.muni.fi.pa165.sme.web.pages.sportActivity.ActivityListPage;
import cz.muni.fi.pa165.sme.web.pages.sportActivityRecord.RecordAddPage;
import cz.muni.fi.pa165.sme.web.pages.sportActivityRecord.RecordListPage;
import cz.muni.fi.pa165.sme.web.pages.user.UserAddPage;
import cz.muni.fi.pa165.sme.web.pages.user.UserListPage;
import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession;
import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

/**
 * @author jirankova
 */
public class SportManagerApplication extends AuthenticatedWebApplication {

	@Override
	public Class<? extends TemplatePage> getHomePage() {
		return RecordListPage.class;
//		return LoginPage.class;
	}

	@Override
	public void init() {
		super.init();

		this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
		this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");

		this.getMarkupSettings().setStripWicketTags(true);

		getComponentInstantiationListeners().add(new SpringComponentInjector(this));

		//page links
		mountPage("/records", RecordListPage.class);
		mountPage("/records/add", RecordAddPage.class);

		mountPage("/activities", ActivityListPage.class);
		mountPage("/activities/add", ActivityAddPage.class);

		mountPage("/calories", CaloriesListPage.class);
		mountPage("/calories/add", CaloriesAddPage.class);

		mountPage("/user", UserListPage.class);
		mountPage("/user/add", UserAddPage.class);

		mountPage("/login", LoginPage.class);
	}

	@Override
	protected Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass() {
		return SportManagerAuthenticatedSession.class;
	}

	@Override
	protected Class<? extends WebPage> getSignInPageClass() {
		return LoginPage.class;
	}
}
